<%@page contentType="text/html;charset=UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="${ctx }/scripts/plugin/ajaxfileupload.js"></script>
<script>
$(document).ready(function() {
	$("#reportStartdate").addClass("Wate").bind("click", function() {
		WdatePicker({
			skin : 'whyGreen',
			dateFmt : 'yyyy-MM-dd'
		});
	});
		
	$("#sub").click(function(){
		var startTime = $("#reportStartdate").val();
		var endTime = $("#effectiveDate").val();
		var id = $("#id").val();
		if(startTime == "" || endTime==""){
			alert("请输入签订日期和有效日期！");
			return false;
		}
		$.ajaxFileUpload({
			  url:'${ctx }/contract/document!modk.action?id='+id+'&signTime='+startTime+'&effectiveDate='+endTime,//服务器端程序
			  secureuri:false,
			  fileElementId:'upload',//input框的ID
			  dataType: 'text/plain',//返回数据类型
			  beforeSend:function(){//上传前需要处理的工作，如显示Loading...
			  },
			  success: function (data){//上传成功
			      //从data中获取数据，进行处理
			    window.parent.load();
			  }
			});
	});
	
});
	
	</script>
<title>Insert title here</title>
</head>
<body>
<form action="${ctx }/contract/document!modk.action" method="get" id="inputForm" class='yform' enctype="multipart/form-data">
<input type="hidden" name="id" value="${id }" id="id"/>
<div id="caption">
			<h6>签订和有效日期</h6>
		</div>
<div id="content">
<table>
	<tr>
	<td>签订日期</td>
	<td><input type="text" id="reportStartdate" name="signTime" value="<fmt:formatDate value="${signTime}" pattern="yyyy-MM-dd" />" />
	</td>
	</tr>
	<tr>
	<td>有效日期</td>
	<td><input type="text" id="effectiveDate" name="effectiveDate" value="${effectiveDate}" /></td>
	</tr>
	<tr>
	<td>附件</td>
	<td><input type="file" id="upload" name="upload"/></td>
	</tr>
	<c:if test="${not empty attachment.id}">
	<tr id="attachment">
	<td>已有附件</td>
	<td>
	<a title="下载" href="${ctx}/servlet/annex?id=${attachment.id}">${attachment.upfileFileName}</a>
				<span onclick="deleteAttachment('${attachment.id}')" class="delete" title="删除附件"></span>
	</td>
	</tr></c:if>
</table>
</div>
<div class="type-button">
<input class="submit" type="button"  id="sub" value="确定" />
<input class="submit" type="button"  onclick="window.parent.close();" value="关闭" />
</div>
</form>
</body>
</html>